/**
 * Description:一些注释<br/>
 * CreateTime:2019-03-27<br/>
 * Creater: yangpengfei360@126.com <br/>
 * @author yangpengfei
 */
package cn.cnsy123.bookwebsiteserver.controller.menu;

import java.util.List;

import javax.servlet.http.HttpServletRequest;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import cn.cnsy123.bookwebsiteserver.cache.UserCacheInfo;
import cn.cnsy123.bookwebsiteserver.constant.CacheConstant;
import cn.cnsy123.bookwebsiteserver.service.menu.MenuInfoService;
import cn.cnsy123.bookwebsiteserver.vo.MenuResult;
import cn.cnsy123.bookwebsiteserver.vo.ztree.TreeResult;

/**
 * Description:一些注释<br/>
 * CreateTime:2019-03-27<br/>
 * Creater: yangpengfei360@126.com <br/>
 * @author yangpengfei
 */
@RestController
public class MenuController {
    
    @Autowired
    private MenuInfoService menuInfoService;
    
    @GetMapping(value = "/menu")
    public List<MenuResult> findMenuBarInfo(HttpServletRequest request) {
        UserCacheInfo cacheInfo = (UserCacheInfo)request.getSession().getAttribute(CacheConstant.SESSION_USER);
        return menuInfoService.findMenuBarInfo(cacheInfo.getUserId());
    }
    
    @GetMapping(value = "/rolePriv/menu")
    public List<TreeResult> findRolePrivMenuBarInfo() {
        //UserCacheInfo cacheInfo = (UserCacheInfo)request.getSession().getAttribute(CacheConstant.SESSION_USER);
        return menuInfoService.findRolePrivMenuBarInfo();
    }

}
